package handler

import (
	api "gitee.com/yanwc/gozero-utils/api"
	"net/http"

	"dnsresolver/internal/logic"
	"dnsresolver/internal/svc"
	"dnsresolver/internal/types"
	"github.com/zeromicro/go-zero/rest/httpx"
)

func GetAddressListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		var req types.GetAddressListReq
		if err := httpx.Parse(r, &req); err != nil {
			httpx.Error(w, err)
			return
		}

		l := logic.NewGetAddressListLogic(r.Context(), svcCtx)
		resp, err := l.GetAddressList(&req)
		api.HttpResult(r, w, resp, err)
	}
}
